<template>
    <div>

    <section class="menu-block">
            <h2>微信分享网页</h2>
            <div class="menu-block">
                <pre v-highlightA>
                    <code>
import { page } from 'fzHybrid'
...
wxshare.link({
    type: 'session',   //微信分享发送的目标场景，必填(session:好友,timeline:朋友圈 )
    url:'',        //网页html链接,必填
    title:'',      //标题
    description:'',//描述
    thumbImg:''        //网页缩略图,
    callback:function(result){}  //result:微信返回的errorCode值
})
                    </code>
                </pre>
                <van-cell-group>
                    <van-field v-model="linkType" label="type" placeholder="请输入type" />
                    <van-field v-model="linkUrl" label="url" placeholder="请输入url" />
                    <van-field v-model="linkTitle" label="title" placeholder="请输入title" />
                    <van-field v-model="linkDescription" label="description" placeholder="请输入description" />
                    <van-field v-model="linkThumbImg" label="thumbImg" placeholder="请输入thumbImg" />
                </van-cell-group>
                <van-button size="large" type="primary" @click="shareLinkClick">点击分享网页</van-button>
                <code>返回结果：{{ resultstr }}</code>
            </div>
        </section>
        <section class="menu-block">
            <h2>微信分享图片</h2>
            <div class="menu-block">
                <pre v-highlightA>
                    <code>
import { page } from 'fzHybrid'
...
wxshare.img({
    type: 'session',   //微信分享发送的目标场景，必填(session:朋友圈,timeline:朋友圈 )
    url:'',        //图片地址,必填
    callback:function(result){}
})
                    </code>
                </pre>
                <van-cell-group>
                    <van-field v-model="imgType" label="type" placeholder="请输入type" />
                    <van-field v-model="imgUrl" label="url" placeholder="请输入url" />
                </van-cell-group>
                <van-button size="large" type="primary" @click="shareImgClick">点击分享图片</van-button>
                <code>返回结果：{{ imgResultStr }}</code>
            </div>
        </section>
        <section class="menu-block">
            <h2>微信分享文字</h2>
            <div class="menu-block">
                <pre v-highlightA>
                    <code>
import { page } from 'fzHybrid'
...
wxshare.text({
    type: 'session',   //微信分享发送的目标场景，必填(session:好友,timeline:朋友圈 )
    text:'',        //文字内容,必填
    callback:function(result){}
})
                    </code>
                </pre>
                <van-cell-group>
                    <van-field v-model="textType" label="type" placeholder="请输入type" />
                    <van-field v-model="textText" label="text" placeholder="请输入text" />
                </van-cell-group>
                <van-button size="large" type="primary" @click="shareTextClick">点击分享文字</van-button>
                <code>返回结果：{{ textResultStr }}</code>
            </div>
        </section>
    </div>
</template>

<script>
import {Button, CellGroup, Cell, Field, Notify, Checkbox} from 'vant'
import { wxshare } from 'MTHybrid'

export default {
    data () {
        return {
            linkType: 'session',
            linkUrl: 'https://appdist.tingmimi.net/h5/mainMeeting1.html?uid=1',
            linkTitle: '',
            linkDescription: '',
            linkThumbImg: '',
            imgType: 'session',
            imgUrl: '',
            textType: 'session',
            textText: '',
            resultstr: '',
            imgResultStr: '',
            textResultStr: ''
        }
    },
    methods: {
        shareLinkClick () {
            const thiz = this
            wxshare.link({
                type: this.linkType,
                url: this.linkUrl,
                title: this.linkTitle,
                description: this.linkDescription,
                thumbImg: this.linkThumbImg,
                callback: function (result) {
                    thiz.resultstr = result
                }
            })
        },
        shareImgClick () {
            const thiz = this
            wxshare.img({
                type: this.imgType,
                url: this.imgUrl,
                callback: function (result) {
                    thiz.imgResultStr = result
                }
            })
        },
        shareTextClick () {
            const thiz = this
            wxshare.text({
                type: this.textType,
                text: this.textText,
                callback: function (result) {
                    thiz.textResultStr = result
                }
            })
        }
    },
    components: {
        [Button.name]: Button,
        [Cell.name]: Cell,
        [CellGroup.name]: CellGroup,
        [Field.name]: Field,
        [Notify.name]: Notify,
        [Checkbox.name]: Checkbox
    }
}
</script>

<style>
    @import '../../../static/css/index.css';
    .menu-block {
        padding: 0 0.2rem
    }
    h2 {
        margin-block-start: 0.83em;
        margin-block-end: 0.83em;
        margin-inline-start: 0px;
        margin-inline-end: 0px;
        margin: 0;
        /* font-weight: 200; */
        font-size: 18px;
        color: rgba(69,90,100,.6);
        padding: 20px 15px 15px;
    }
</style>
